package tt.dz.biz.dao.financial;

import java.util.List;
import org.springframework.stereotype.Repository;
import tt.dz.biz.dao.BaseDAO;
import tt.dz.vo.ChannelBankaccountVO;

@Repository("channelBankAccountDAO")
public class ChannelBankAccountDAO
  extends BaseDAO
{
  private static final String LIST_ALL_CHANNLE_SUBJECT = "select  a.subject_code,a.channel_code,a.is_valid  from ms_channel_bankaccount as a ";
  private static final String INSERT_CHANNLE_SUBJECT = "insert into ms_channel_bankaccount(subject_code,channel_code,is_valid)  values(:subjectCode,:channelCode,:isValid )";
  private static final String UPDATE_CHANNLE_SUBJECT = "update  ms_channel_bankaccount set is_valid = :isValid where subject_code = :subjectCode and channel_code = :channelCode";
  
  public List<ChannelBankaccountVO> listAllChannelSubject()
  {
    return queryForList("select  a.subject_code,a.channel_code,a.is_valid  from ms_channel_bankaccount as a ", null, ChannelBankaccountVO.class);
  }
  
  public int insertChannelSubject(ChannelBankaccountVO channelBankaccountVO)
  {
    return save("insert into ms_channel_bankaccount(subject_code,channel_code,is_valid)  values(:subjectCode,:channelCode,:isValid )", channelBankaccountVO);
  }
  
  public int updateChannelSubject(ChannelBankaccountVO channelBankaccountVO)
  {
    return save("update  ms_channel_bankaccount set is_valid = :isValid where subject_code = :subjectCode and channel_code = :channelCode", channelBankaccountVO);
  }
  
  public List<ChannelBankaccountVO> queryChannelBankAccountBychannelCode(String channelCode)
  {
    StringBuilder sql = new StringBuilder("select  a.subject_code,a.channel_code,a.is_valid  from ms_channel_bankaccount as a ");
    sql.append("  where channel_code =:channelCode and is_valid = 1");
    ChannelBankaccountVO param = new ChannelBankaccountVO();
    param.setChannelCode(channelCode);
    return queryForList(sql.toString(), param, ChannelBankaccountVO.class);
  }
}
